package cn.stylefeng.guns.modular.gridsystem.controller;

import cn.stylefeng.guns.core.annotion.BusinessLog;
import cn.stylefeng.guns.core.enums.LogAnnotionOpTypeEnum;
import cn.stylefeng.guns.core.pojo.response.ResponseData;
import cn.stylefeng.guns.core.pojo.response.SuccessResponseData;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import cn.stylefeng.guns.modular.gridsystem.service.BizGatewayTemperatureService;
import cn.stylefeng.guns.modular.gridsystem.model.param.BizGatewayTemperatureParam;

import javax.annotation.Resource;

/**
 * 网关温度 控制器
 *
 * @author: ssy
 * @date: 2022/08/12 16:00
 */
@RestController
public class BizGatewayTemperatureController {

    @Resource
    private BizGatewayTemperatureService bizGatewayTemperatureService;

    /**
     * 分页查询网关温度
     *
     * @author ssy
     * @date 2022/08/12 16:00
     */
    @GetMapping("/bizGatewayTemperature/page")
    @BusinessLog(title = "网关温度_分页查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData page(BizGatewayTemperatureParam bizGatewayTemperatureParam) {
        return new SuccessResponseData(bizGatewayTemperatureService.pageList(bizGatewayTemperatureParam));
    }

    /**
     * 获取全部网关温度
     *
     * @author ssy
     * @date 2022/08/12 16:00
     */
    @GetMapping("/bizGatewayTemperature/list")
    @BusinessLog(title = "网关温度_查询所有", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData list( ) {
        return new SuccessResponseData(bizGatewayTemperatureService.list());
    }

    /**
     * 查看详情网关温度
     *
     * @author ssy
     * @date 2022/08/12 16:00
     */
    @GetMapping("/bizGatewayTemperature/detail")
    @BusinessLog(title = "网关温度_查看详情", opType = LogAnnotionOpTypeEnum.DETAIL)
    public ResponseData detail(@Validated(BizGatewayTemperatureParam.detail.class) BizGatewayTemperatureParam bizGatewayTemperatureParam) {
        return new SuccessResponseData(bizGatewayTemperatureService.detail(bizGatewayTemperatureParam));
    }

    /**
     * 添加网关温度
     *
     * @author ssy
     * @date 2022/08/12 16:00
     */
    @PostMapping("/bizGatewayTemperature/add")
    @BusinessLog(title = "网关温度_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public ResponseData add(@RequestBody @Validated(BizGatewayTemperatureParam.add.class) BizGatewayTemperatureParam bizGatewayTemperatureParam) {
        bizGatewayTemperatureService.add(bizGatewayTemperatureParam);
        return new SuccessResponseData();
    }

    /**
     * 删除网关温度
     *
     * @author ssy
     * @date 2022/08/12 16:00
     */
    @PostMapping("/bizGatewayTemperature/delete")
    @BusinessLog(title = "网关温度_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData delete(@RequestBody @Validated(BizGatewayTemperatureParam.delete.class) BizGatewayTemperatureParam bizGatewayTemperatureParam) {
        bizGatewayTemperatureService.delete(bizGatewayTemperatureParam);
        return new SuccessResponseData();
    }

    /**
     * 编辑网关温度
     *
     * @author ssy
     * @date 2022/08/12 16:00
     */
    @PostMapping("/bizGatewayTemperature/edit")
    @BusinessLog(title = "网关温度_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData edit(@RequestBody @Validated(BizGatewayTemperatureParam.edit.class) BizGatewayTemperatureParam bizGatewayTemperatureParam) {
        bizGatewayTemperatureService.edit(bizGatewayTemperatureParam);
        return new SuccessResponseData();
    }



    /**
     * echart查询时间段的温度
     *
     * @author rdp
     * @date 2022/11/02 09:58
     */
    @GetMapping("/bizGatewayTemperature/getTemperatureByDate")
    @BusinessLog(title = "网关温度_查询时间段的温度", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData getTemperatureByDate(BizGatewayTemperatureParam bizGatewayTemperatureParam) {
        return new SuccessResponseData(bizGatewayTemperatureService.getTemperatureByDate(bizGatewayTemperatureParam));
    }

}
